package com.arpa.wms.domain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 出货单
 * </p>
 *
 * @author LEO
 * @since 2020-08-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("wms_delivery")
@ApiModel(value="Delivery对象", description="出货单")
public class Delivery extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "出货单号")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "仓库")
    @TableField("warehouse_code")
    private String warehouseCode;

    @ApiModelProperty(value = "入驻商")
    @TableField("shipment_code")
    private String shipmentCode;

    @ApiModelProperty(value = "入驻商")
    @TableField("shipment_name")
    private String shipmentName;

    @ApiModelProperty(value = "供应商,发货退货单关联的收货单的供应商")
    @TableField("supplier_code")
    private String supplierCode;

    @ApiModelProperty(value = "所属机构")
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "客户")
    @TableField("customer_code")
    private String customerCode;

    @ApiModelProperty(value = "版本号")
    @TableField("version")
    @Version
    private Integer version;

    @ApiModelProperty(value = "来源单号")
    @TableField("source_code")
    @Length(max = 100, message = "来源单号长度不能大于100个字符", groups = {Save.class, Update.class})
    private String sourceCode;

    @ApiModelProperty(value = "非基本单位总数量")
    @TableField("total_num")
    private BigDecimal totalNum;

    @ApiModelProperty(value = "分配数量（基本单位数量）")
    @TableField("distribution_num")
    private BigDecimal distributionNum;

    @ApiModelProperty(value = "分拣数量")
    @TableField("pick_num")
    private BigDecimal pickNum;

    @ApiModelProperty(value = "发货数量")
    @TableField("send_num")
    private BigDecimal sendNum;

    @ApiModelProperty(value = "退货总数量")
    @TableField("refund_quantity")
    private BigDecimal refundQuantity;

    @ApiModelProperty(value = "单据类型")
    @TableField("type")
    private String type;

    @ApiModelProperty(value = "状态,0-新增。1-待分配，2-部分分配，3-已分配，4-已作废,5生成波次中，6待拣货，7待复核，8复核中，9待发货，10发货中，11发货完成")
    @TableField("status")
    private String status;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 100, message = "备注长度不能大于100个字符", groups = {Save.class, Update.class})
    private String remarks;

    @ApiModelProperty(value = "出货单明细列表")
    @TableField(exist = false)
    @Valid
    private List<DeliveryItem> deliveryItemList;

    @ApiModelProperty(value = "是否oms下发的；0：否；1：是；用于后期判断反填oms数据")
    @TableField("is_oms_order")
    private Integer isOmsOrder;

    @ApiModelProperty(value = "波次单号")
    @TableField("wave_picking_code")
    private String wavePickingCode;

    /**
     * 奇门传递过来的出库单号
     */
    @ApiModelProperty(value = "奇门传递过来的出库单号")
    @TableField("delivery_order_code")
    private String deliveryOrderCode;

    /**
     * 面单号
     */
    @ApiModelProperty(value = "面单号")
    @TableField("waybill_code")
    private String waybillCode;

    /**
     * 物流公司编码(SF=顺丰、EMS=标准快递、EYB=经济快件、ZJS=宅急送、YTO=圆通 、ZTO=中 通(ZTO)、HTKY=百世汇通、UC=优速、STO=申通、TTKDEX=天天快递、QFKD=全峰、FAST=快捷 、POSTB=邮政小包、 GTO=国通、YUNDA=韵达、JD=京东配送、DD=当当宅配、AMAZON=亚马逊物流、 OTHER=其他)
     */
    @ApiModelProperty(value = "物流公司编码")
    @TableField("logistics_code")
    private String logisticsCode;

    /**
     * 出库单类型(JYCK=一般交易出库单;HHCK=换货出库单;BFCK=补发出库单;QTCK=其他出库单)
     */
    @ApiModelProperty(value = "出库单类型(JYCK=一般交易出库单;HHCK=换货出库单;BFCK=补发出库单;QTCK=其他出库单)")
    @TableField("order_type")
    private String orderType;


    /**
     * 前台订单/店铺订单的创建时间/下单时间
     */
    @ApiModelProperty(value = "前台订单/店铺订单的创建时间/下单时间")
    @TableField("place_order_time")
    private String placeOrderTime;

    /**
     * 店铺名称
     */
    @ApiModelProperty(value = "店铺名称")
    @TableField("shop_nick")
    private String shopNick;


    /**
     * 发件人名称
     */
    @ApiModelProperty(value = "发件人名称")
    @TableField("sender_name")
    private String senderName;

    /**
     * 发件人移动电话
     */
    @ApiModelProperty(value = "发件人移动电话")
    @TableField("sender_mobile")
    private String senderMobile;

    /**
     * 发件人省份
     */
    @ApiModelProperty(value = "发件人省份")
    @TableField("sender_province")
    private String senderProvince;

    /**
     * 发件人城市
     */
    @ApiModelProperty(value = "发件人城市")
    @TableField("sender_city")
    private String senderCity;

    /**
     * 发件人区县
     */
    @ApiModelProperty(value = "发件人区县")
    @TableField("sender_district")
    private String senderDistrict;

    /**
     * 发件人详细地址
     */
    @ApiModelProperty(value = "发件人详细地址")
    @TableField("sender_detail_address")
    private String senderDetailAddress;

    /**
     * 收件人姓名
     */
    @ApiModelProperty(value = "收件人姓名")
    @TableField("receiver_name")
    private String receiverName;

    /**
     * 收件人移动电话
     */
    @ApiModelProperty(value = "收件人移动电话")
    @TableField("receiver_mobile")
    private String receiverMobile;

    /**
     * 收件人省份
     */
    @ApiModelProperty(value = "收件人省份")
    @TableField("receiver_province")
    private String receiverProvince;

    /**
     * 收件人城市
     */
    @ApiModelProperty(value = "收件人城市")
    @TableField("receiver_city")
    private String receiverCity;

    /**
     * 收件人区县
     */
    @ApiModelProperty(value = "收件人区县")
    @TableField("receiver_district")
    private String receiverDistrict;

    /**
     * 收件人详细地址
     */
    @ApiModelProperty(value = "收件人详细地址")
    @TableField("receiver_detail_address")
    private String receiverDetailAddress;

    /**
     * 明细信息用到的商品数据，key为goodCode，商品编码
     */
    @ApiModelProperty(value = "明细信息用到的商品数据，key为goodCode，商品编码")
    @TableField(exist = false)
    private Map<String, Goods> useGoods;

    /**
     * 接口联调customerId
     */
    @ApiModelProperty(value = "接口联调customerId")
    @TableField("customer_id")
    private String customerId;

    @ApiModelProperty(value = "复核数量")
    @TableField("recheck_quantity")
    private BigDecimal recheckQuantity;


    @ApiModelProperty(value = "订单来源平台编码(TB=淘宝、TM=天猫、JD=京东、DD=当当、PP=拍拍、YX= 易讯、 EBAY=ebay、QQ=QQ网购、" +
            "AMAZON=亚马逊、SN=苏宁、GM=国美、WPH=唯品会、JM=聚美、LF=乐蜂 、MGJ=蘑菇街、 JS=聚尚、PX=拍鞋、YT=银泰、YHD=1号店、VANCL=凡客、" +
            "YL=邮乐、YG=优购、1688=阿 里巴巴、POS=POS门店、 MIA=蜜芽、OTHER=其他(只传英文编码))")
    @TableField("source_platform_code")
    private String sourcePlatformCode;

    @ApiModelProperty(value = "签名")
    @TableField("signature")
    private String signature;

    @ApiModelProperty(value = "面单标准模板地址")
    @TableField("template_url")
    private String templateUrl;

    @ApiModelProperty(value = "是否取消： 0 否； 1 是")
    @TableField("is_cancel")
    private Integer isCancel;

    @ApiModelProperty(value = "临时码用于波次创建查询")
    @TableField("temporary_code")
    private String temporaryCode;

    @ApiModelProperty(value = "商品种类数量")
    @TableField("goods_sort_quantity")
    private BigDecimal goodsSortQuantity;

    @ApiModelProperty(value = "单据来源；wms: 手工创建； oms：OMS；qimen：奇门； other：其他；")
    @TableField("source_type")
    private String sourceType;

    @ApiModelProperty(value = "isvCode")
    @TableField("isv_code")
    private String isvCode;

    /**
     * 仓库编码
     */
    @ApiModelProperty(hidden = true)
    @TableField("warehouse_serial_number")
    private String warehouseSerialNumber;

    /**
     * 订单标识
     */
    @ApiModelProperty(value = "订单标识")
    @TableField("order_tag")
    private String orderTag;
    /**
     * 订单排序
     */
    @ApiModelProperty(value = "订单排序")
    @TableField("order_num")
    private Integer orderNum;

    /**
     * 承运商编码
     */
    @ApiModelProperty(value = "承运商编码")
    @TableField("carrier_code")
    private String carrierCode;

    /**
     * 承运商名称
     */
    @ApiModelProperty(value = "承运商名称")
    @TableField("carrier_name")
    private String carrierName;

    @ApiModelProperty(value = "拣货缺货数量")
    @TableField("pick_stock_out_num")
    private BigDecimal pickStockOutNum;

    @ApiModelProperty(value = "复核缺货数量")
    @TableField("recheck_refund_quantity")
    private BigDecimal recheckRefundQuantity;


    /**
     * 承运商编码
     */
    @ApiModelProperty(value = "面单打印信息")
    @TableField("print_data")
    private String printData;
    /**
     * 承运商编码
     */
    @ApiModelProperty(value = "三段码")
    @TableField("route_code")
    private String routeCode;
    /**
     * 承运商编码
     */
    @ApiModelProperty(value = "集包地编码")
    @TableField("consolidation")
    private String consolidation;

    /**
     * 快递类型
     */
    @ApiModelProperty(value = "快递类型")
    @TableField("carrier_type")
    private String carrierType;

    /**
     * 缺货是否发货标识 0-不发货  1-发货
     */
    @ApiModelProperty(value = "缺货是否发货标识")
    @TableField("is_delivering_if_stockout")
    private Integer isDeliveringIfStockout;

    /**
     * 面单打印次数
     */
    @ApiModelProperty(value = "面单打印次数")
    @TableField("waybill_print_count")
    private Integer waybillPrintCount;

    /**
     * 打包任务下发:0否1是
     */
    @ApiModelProperty(value = "打包任务下发:0否1是")
    @TableField("is_pack_issue")
    private Integer packIssue;

    /**
     * 贴单任务下发:0否1是
     */
    @ApiModelProperty(value = "贴单任务下发:0否1是")
    @TableField("is_paste_issue")
    private Integer pasteIssue;

    /**
     * 是否预打包订单:0否1是
     */
    @ApiModelProperty(value = "是否预打包订单:0否1是")
    @TableField("is_prepackaged")
    private Integer prepackaged;

    @ApiModelProperty(value = "预打包单号")
    @TableField("prepackaged_code")
    private String prepackagedCode;


    @ApiModelProperty(value = "收件人ID")
    @TableField("oaid")
    private String oaid;

    @ApiModelProperty(value = "体积")
    @TableField("volume")
    private BigDecimal volume;

    @ApiModelProperty(value = "包材名称")
    @TableField("packing_material_name")
    private String packingMaterialName;

    @TableField("tid")
    private String tid;


    @TableField("user_id")
    private String userId;


    @ApiModelProperty(value = "包裹数")
    @TableField("package_num")
    private Integer packageNum;

    @ApiModelProperty(value = "拆分运单号")
    @TableField("split_waybill_code")
    private String splitWaybillCode;

    /**
     * 出库完成时间
     */
    @ApiModelProperty(value = "出库完成时间")
    @TableField(value = "outbound_completion_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime outboundCompletionTime;

    @ApiModelProperty(value = "获取面单失败原因")
    @TableField("failure_reason_of_getting_waybill")
    private String failureReasonOfGettingWaybill;

    @ApiModelProperty(value = "任务状态，1-未执行，2-执行中，3-执行完成")
    @TableField("task_status")
    private String taskStatus;

    public interface Save{}
    public interface Update{}

}
